package day4;

public class Test2 {
    public static void main(String[] args) {
        //使用二维数组，打印输出杨辉三角
        //定义二维数组
        int[][] arr = new int[6][7];
        arr[0][0]=1;
        //存放杨辉三角
        for (int i = 1; i <arr.length ; i++) {
            for (int j = 1; j <arr[i].length ; j++) {
                arr[i][j] = arr[i-1][j-1]+arr[i-1][j];
            }
        }
        //输出杨辉三角
        for (int i = 1; i <arr.length ; i++) {
            for (int j = 1; j <=i ; j++) {
                System.out.print(arr[i][j]+" ");
            }
            System.out.println();
        }
    }
}
